﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SharpErp.Data.Common.Entity
{
    [Serializable]
    [Table("production_nine_class")]
    public class ProductionNineClass : BaseEntity
    {
        [Column("id")]
        public int Id { get; set; }

        [Column("parent_id")]
        public int ParentId { get; set; }

        [Column("name")]
        public string Name { get; set; }

        [Column("code")]
        public string Code { get; set; }

        [Column("standard")]
        public string Standard { get; set; }

        [Column("length")]
        public string Length { get; set; }

        [Column("width")]
        public string Width { get; set; }

        [Column("pcount")]
        public string Pcount { get; set; }

        [Column("unit")]
        public string Unit { get; set; }

        [Column("requirement")]
        public string Requirement { get; set; }

        [Column("goods")]
        public string Goods { get; set; }

        [Column("facility")]
        public string Facility { get; set; }

        [Column("safe_time")]
        public string SafeTime { get; set; }

        [Column("qichu")]
        public int Qichu { get; set; }

        [Column("xianchu")]
        public int Xianchu { get; set; }

        [Column("inventory")]
        public int Inventory { get; set; }

        [Column("material")]
        public string Material { get; set; }

        [Column("parent_desc")]
        public string ParentDesc { get; set; }

        [Column("goods_desc")]
        public string GoodsDesc { get; set; }

        [Column("manufactor")]
        public string Manufactor { get; set; }

        [NotMapped]
        private List<string> goodsNameList;

        private void InitGoodsNameList()
        {
            if (string.IsNullOrEmpty(GoodsDesc)) return;
            if (goodsNameList == null) goodsNameList = new List<string>(this.GoodsDesc.Split(new string[] { Util.Constants.NAME_SEPERATOR }, System.StringSplitOptions.None));
        }

        public string GoodsSecondName
        {
            get
            {
                InitGoodsNameList();
                if (goodsNameList != null && goodsNameList.Count > 1) return goodsNameList[1];
                return "";
            }
        }
        public string GoodsThirdName
        {
            get
            {
                InitGoodsNameList();
                if (goodsNameList != null && goodsNameList.Count > 2) return goodsNameList[2];
                return "";
            }
        }

        public string GoodsForthFifthSixName
        {
            get
            {

                InitGoodsNameList();
                if (goodsNameList != null && goodsNameList.Count > 5) return  goodsNameList[3] + goodsNameList[4] + goodsNameList[5];
                return "";
            }
        }

        public string GoodsSevenName
        {
            get
            {

                InitGoodsNameList();
                if (goodsNameList != null && goodsNameList.Count > 8) return  goodsNameList[6] + " 长:" + goodsNameList[7] + " 高:" + goodsNameList[8];
                return "";
            }

        }

        public string PCountUnitName
        {
            get
            {

                InitGoodsNameList();
                if (goodsNameList != null && goodsNameList.Count > 10) return goodsNameList[9] + goodsNameList[10];
                return "";
            }

        }
    }
}
